/**
 * 作业管理——待提交
 */

 import { LineChartOutlined } from '@ant-design/icons';
 import { Link } from 'react-router-dom';
 import { history } from 'umi';
 import {
   DatePicker,
   Space,
   Input,
   Select,
   Table,
   Tag,
   Tabs,
   Button,
   Form,
 } from 'antd';
 import React, { useState } from 'react';
 import request from '@/http';
 import All_style from '../../index.less';
 
 const { RangePicker } = DatePicker;
 const { TabPane } = Tabs;
 const { Option } = Select;
 
 const columns = [
   {
     title: '发布时间',
     dataIndex: 'createTime',
     key: 'createTime',
   },
   {
     title: '项目名称',
     dataIndex: 'courseName',
     key: 'courseName',
   },
   {
     title: '作业主题',
     dataIndex: 'title',
     key: 'title',
   },
   {
     title: '作业类型',
     dataIndex: 'workType',
     key: 'workType',
   },
   {
     title: '实训老师',
     dataIndex: 'teacherName',
     key: 'teacherName',
   },
   {
     title: '计划完成时间',
     dataIndex: 'completeDate',
     key: 'completeDate',
   },
   {
     title: '作业完成状态',
     dataIndex: 'workStatus',
     key: 'workStatus',
   },
   {
     title: '实际完成时间',
     dataIndex: 'completeDate',
     key: 'completeDate',
   },
 ];
 const dataOld = [
   {
     completeDate: '',
     ompleteTime: '',
     courseName: '',
     createTime: '',
     id: '',
     score: '',
     teacherName: '',
     title: '',
     workStatus: '',
     workType: '',
     key: '',
     workId: '',
     active: '',
   },
 ];
 const NoReply = (props: any) => {
   // 绑定下拉框的接口
   const [courseName, setCourseName] = React.useState([]);
   const getCourseName = async () => {
     const CourseName: any = await request.put(
       '/user_info_manage/getCourseName',
     );
     setCourseName(CourseName.data);
   };
 
   const [workType, setWorkType] = React.useState([]);
   const getWorkType = async () => {
     const WorkType: any = await request.put('/user_info_manage/getWorkType');
     setWorkType(WorkType.data);
   };
 
   const [teacherName, setTeacherName] = React.useState([]);
   const getTeacherName = async () => {
     const TeacherName: any = await request.put(
       '/user_info_manage/getTeacherName',
     );
     setTeacherName(TeacherName.data);
   };
   /**------------------------------------------------------------------------------ */
   const [data, setData] = React.useState(dataOld);
   //显示
   const [formObject] = Form.useForm();
   interface pageInfoTypes {
     current: number;
     pageSize: number;
     total: number;
     onChange: any;
   }
   const onCurrentChange = (page: any, pageSize: any) => {
     loadData(page, pageInfo.pageSize);
   };
   const [pageInfo, setPageInfo] = useState<pageInfoTypes>({
     current: 1,
     pageSize: 5,
     total: 0,
     onChange: onCurrentChange,
   });
   const loadData = async (current: any, pageSize: any) => {
     const datas = await formObject.validateFields();
     console.log(datas);
     const result: any = await request.post(
       '/work-submit-info-entity/jobManagement_s',
       {
         current: current,
         size: pageSize,
         type: '待批复',
         ...datas,
         vacationEndDate: datas?.workPubTime
           ? datas?.workPubTime[1]?.format('YYYY-MM-DD HH:mm:ss')
           : '',
         vacationBeginDate: datas?.workPubTime
           ? datas?.workPubTime[0]?.format('YYYY-MM-DD HH:mm:ss')
           : '',
         workPlanTime: datas?.workPlanTime
           ? datas?.workPlanTime?.format('YYYY-MM-DD HH:mm:ss')
           : '',
       },
     );
     console.log(result);
     if (result.code == '200') {
       const newData = result.date.info.map((d: any, index: any) => {
         return {
           key: `k_${index}`,
           ...d,
         };
       });
       setData(newData);
       setPageInfo({
         current: result?.data?.paginationData?.currentPage,
         pageSize: result?.data?.paginationData?.number,
         total: result?.data?.paginationData?.sum,
         onChange: pageInfo.onChange,
       });
     }
   };
   //查询
 
   //重置按钮
   const onReset = () => {
     formObject.resetFields();
     loadData(pageInfo.current, pageInfo.pageSize);
   };
   React.useEffect(() => {
     loadData(pageInfo.current, pageInfo.pageSize);
      //  getCourseName();
      //  getWorkType();
      //  getTeacherName();
   }, []);
 
   return (
     <div className={All_style.box}>
       <Form name="SelectLeaveForm" form={formObject} preserve={false}>
         <div>
           <Form.Item
             name="createTime"
             label="发布时间："
             style={{ float: 'left' }}
             className={All_style.data}
           >
             <RangePicker showTime className={All_style.select} />
           </Form.Item>
 
           <Form.Item
             name="courseName"
             label="项目名称："
             style={{ float: 'left' }}
             className={All_style.formItem}
           >
             <Select placeholder="请选择" className={All_style.select}>
               {courseName.map((c, index) => {
                 return (
                   <Option key={`k_${index}`} value={c}>
                     {c}
                   </Option>
                 );
               })}
             </Select>
           </Form.Item>
 
           <Form.Item
             name="title"
             label="作业主题："
             style={{ float: 'left' }}
             className={All_style.formItem}
           >
             <Input placeholder="请录入" className={All_style.select}></Input>
           </Form.Item>
 
             <Form.Item
               name="workType"
               label="作业类型："
               style={{ float: 'left' }}
               className={All_style.formItem}
             >
               <Select placeholder="请选择" className={All_style.select}>
                 {workType.map((c, index) => {
                   return (
                     <Option key={`k_${index}`} value={c}>
                       {c}
                     </Option>
                   );
                 })}
               </Select>
             </Form.Item>
 
             <Form.Item
               name="teacherName"
               label="老师："
               style={{ float: 'left' }}
               className={All_style.formItem}
             >
               <Select placeholder="请选择" className={All_style.select}>
                 {teacherName.map((c, index) => {
                   return (
                     <Option key={`k_${index}`} value={c}>
                       {c}
                     </Option>
                   );
                 })}
               </Select>
             </Form.Item>
 
             <Form.Item
               name="completeDate"
               label="计划完成时间："
               style={{ float: 'left' }}
               className={All_style.data}
             >
               <DatePicker showTime className={All_style.select} />
             </Form.Item>
           <div style={{ clear: 'both', float: 'right', marginRight: 80 }}>
             <Button
               className={All_style.button}
               onClick={() => loadData(pageInfo.current, pageInfo.pageSize)}
             >
               查询
             </Button>
             <Button
               className={All_style.button2}
               htmlType="button"
               onClick={onReset}
             >
               重置
             </Button>
           </div>
         </div>
       </Form>
       <Table
         columns={columns}
         dataSource={data}
         // rowKey={(record) => {
         //   return record?.workId + Date.now(); //在这里加上一个时间戳就可以了
         // }}
         className={All_style.table}
         pagination={pageInfo}
       />
     </div>
   );
 };
 export default NoReply;
